package com.hl.payServer.util;

import com.hl.payServer.util.xml.XmlWriters;
import tk.mybatis.mapper.util.StringUtil;

import java.util.Map;

/**
 * xml和map转换工具
 */
public final class Maps {

    /**
     * Map转换为XML
     * @param params Map参数
     * @return XML字符串
     */
    public static String toXml(final Map<String, String> params) {
        XmlWriters writers = XmlWriters.create();
        for (Map.Entry<String, String> param : params.entrySet()){
            if (StringUtil.isNotEmpty(param.getValue())){
                writers.element(param.getKey(), param.getValue());
            }
        }
        return writers.build();
    }
}
